package com.winit.openapi.mqx.validator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.dubbo.common.utils.StringUtils;
import com.winit.mqx.vo.tp.KuaiDi100TrackingMessage;
import com.winit.openapi.mqx.vo.ValidatorResult;

public class KuaiDi100TrackingMessageValidator {
	
	private static Logger  logger = LoggerFactory.getLogger(KuaiDi100TrackingMessageValidator.class);
	
	public static ValidatorResult validate(KuaiDi100TrackingMessage msg){

		ValidatorResult result = new ValidatorResult();
    	if(null == msg){
    		logger.error("KuaiDi100TrackingMessageValidator -> validate 消息体为不能为空");
    		result.setCode(ValidatorResult.VALIDATE_RESULT_CODE_FAILURE);
    		result.setMsg("消息体为不能为空");
    		return result;
    	}
    	if(StringUtils.isBlank(msg.getOrderNo())){
    		logger.error("KuaiDi100TrackingMessageValidator -> validate orderNo不能为空 msg:{}",msg.toString());
    		result.setCode(ValidatorResult.VALIDATE_RESULT_CODE_FAILURE);
    		result.setMsg("orderNo不能为空 ");
    		return result;
    	}
    	if(StringUtils.isBlank(msg.getTrackingNo())){
    		logger.error("KuaiDi100TrackingMessageValidator -> validate 【TrackingNo】不能为空 msg:{}",msg.toString());
    		result.setCode(ValidatorResult.VALIDATE_RESULT_CODE_FAILURE);
    		result.setMsg("【TrackingNo】不能为空");
    		return result;
    	}
    	result.setCode(ValidatorResult.VALIDATE_RESULT_CODE_SUCCESS);
		result.setMsg("SUCCESS");
		return result;
    	
    
		
	}

}
